#pragma once

#include <zookeeper.h>
#include <string>
#include <boost/utility.hpp>
#include "LogMessage.h"

class zkproxy : public boost::noncopyable
{
public:
	zkproxy();

	zkproxy(const std::string &host,const int &timeoutms);

	~zkproxy();

	bool zk_init();
		
	virtual int handle_create(zhandle_t *zzh, int type, int state, const char *path,void* context);

	virtual int handle_delete(zhandle_t *zzh, int type, int state, const char *path,void* context);

	virtual int handle_change(zhandle_t *zzh, int type, int state, const char *path,void* context);

	virtual int handle_child(zhandle_t *zzh, int type, int state, const char *path,void* context);

	virtual int handle_session(zhandle_t *zzh, int type, int state, const char *path,void* context);

	virtual int handle_notwatching(zhandle_t *zzh, int type, int state, const char *path,void* context);
	
protected:

	void watch_callback(zhandle_t *zkhandle,int type,int state,const char* path,void *watchercrtx);
	
private:

	std::string m_host;
	
	int			m_timeoutms;
	
	zhandle_t	*m_zkhandle;
	
	DECL_LOGGER(logger);
};

